<%@codepage="65001"%>
<%session.codepage="65001"%>
<!-- #include virtual=/inc/dbConn.asp -->
<!-- #include virtual=/inc/function.asp -->
<%
	xMode = Request("xMode")	
	cp = request("cp")
	showSubMenu = "10"
		
	'## ■■ User 정보 가져오기 ■■■■
	userSQL = "SELECT userId, userNm FROM tblUser WHERE delYN='N' AND uLevel<>'05' ORDER BY userNm" 

	Set userRs=Server.CreateObject("ADODB.RecordSet")
	userRs.open userSQL, DbCon, 1
	
	userAll = ""
	If userRs.eof Or userRs.bof Then 
	Else 
		Do Until userRs.eof Or userRs.bof
		
		userAll = userAll & "<option value=""" & userRs("userId") & """>" & userRs("userNm") & "</option>"' & vbcrlf
		userRs.movenext
		Loop 
	End If
	
	'## ■■ 공정타입 정보 가져오기 ■■■■
	pTypeSQL = "SELECT itemCd, itemNm FROM tblComCode WHERE groupCd='0004' AND itemCd<>'30' AND flag='Y' ORDER BY itemSeq" 

	Set pTypeRs=Server.CreateObject("ADODB.RecordSet")
	pTypeRs.open pTypeSQL, DbCon, 1
	
	pTypes = ""
	If pTypeRs.eof Or pTypeRs.bof Then 
	Else 
		Do Until pTypeRs.eof Or pTypeRs.bof
		
		pTypes = pTypes & "<option value=""" & pTypeRs("itemCd") & """>" & pTypeRs("itemNm") & "</option>"' & vbcrlf
		pTypeRs.movenext
		Loop 
	End If
	
	'## ■■ 불량율 가져오기 ■■■■
	curWeekDay = weekday(Date())-2
	If curWeekDay < 0 Then curWeekDay = 7 + curWeekDay End If 

	'## 전주 구하기
	bfWeekStart = dateadd("d",-(7+curWeekDay),Date())
	bfWeekEnd = dateadd("d",-(curWeekDay),Date())	
	bfWeekRate10 = aFieldValue("SELECT  (CAST(SUM(isnull(goodQty,0)) as varchar(10))+'/'+CAST(SUM(isnull(badQty,0)) as varchar(10))) FROM tblOrderResult A INNER JOIN tblOrder B ON A.lotNo=B.lotNo AND A.lotSubNo=B.lotSubNo AND A.lotYear=B.lotYear WHERE A.type='10' AND A.flag='Y' AND B.flag<>'N' AND B.type='L' AND A.workDt >= '" & bfWeekStart & "' AND A.workDt < '" & bfWeekEnd & "'")
	bfWeekRate20 = aFieldValue("SELECT SUM(isnull(badQty,0)) FROM tblOrderResult A INNER JOIN tblOrder B ON A.lotNo=B.lotNo AND A.lotSubNo=B.lotSubNo AND A.lotYear=B.lotYear WHERE A.type='20' AND A.flag='Y' AND B.flag<>'N' AND B.type='L' AND A.workDt >= '" & bfWeekStart & "' AND A.workDt < '" & bfWeekEnd & "'")
	If bfWeekRate10 <> "" Then
		divBfWeekRate = Split(bfWeekRate10,"/")
		If (CDbl(divBfWeekRate(0))+CDbl(divBfWeekRate(1))) > 0 Then 
			bfWeekBadRate = (CDbl(divBfWeekRate(1))+CDbl(bfWeekRate20))/(CDbl(divBfWeekRate(0))+CDbl(divBfWeekRate(1))) * 100
			bfWkBadRate = mkRateFormat(Round(bfWeekBadRate,3))
		Else
			bfWkBadRate= 0 
		End if
	Else
		bfWkBadRate= 0 
	End If
	bfWeekBadRateTxt = "이전주 : " & bfWkBadRate & "%"
	
	'##금주 구하기
	curWeekStart = dateadd("d",-(curWeekDay),Date())
	curWeekEnd = dateadd("d",7,curWeekStart)	
	curWeekRate10 = aFieldValue("SELECT  (CAST(SUM(isnull(goodQty,0)) as varchar(10))+'/'+CAST(SUM(isnull(badQty,0)) as varchar(10))) FROM tblOrderResult A INNER JOIN tblOrder B ON A.lotNo=B.lotNo AND A.lotSubNo=B.lotSubNo AND A.lotYear=B.lotYear WHERE A.type='10' AND A.flag='Y' AND B.flag<>'N' AND B.type='L' AND A.workDt >= '" & curWeekStart & "' AND A.workDt < '" & curWeekEnd & "'")
	curWeekRate20 = aFieldValue("SELECT  (CAST(isnull(SUM(badQty),0) as varchar(10))) FROM tblOrderResult A INNER JOIN tblOrder B ON A.lotNo=B.lotNo AND A.lotSubNo=B.lotSubNo AND A.lotYear=B.lotYear WHERE A.type='20' AND A.flag='Y' AND B.flag<>'N' AND B.type='L' AND workDt >= '" & curWeekStart & "' AND workDt < '" & curWeekEnd & "'")
	If curWeekRate10 <> "" Then 
		divCurWeekRate = Split(curWeekRate10,"/")
		If (CDbl(divCurWeekRate(0))+CDbl(divCurWeekRate(1))) > 0 Then 
			curWeekBadRate = (CDbl(divCurWeekRate(1))+CDbl(curWeekRate20))/(CDbl(divCurWeekRate(0))+CDbl(divCurWeekRate(1))) * 100
			curWkBadRate = mkRateFormat(Round(curWeekBadRate,3))
		Else 
			curWkBadRate= 0 
		End If 
	Else
		curWkBadRate = 0
	End If 
	curWeekBadRateTxt = "금주 : <span style='font-size:15px;font-weight:bold;color:#FF0000'>" & curWkBadRate & "%</span>"
%>
<!-- #include virtual=/inc/header.inc.asp -->  

<script language="javascript">
	$(window).load(function(){
		setMainMenu();
		fnShowCalendar();
		intervalNotice();
		fnCommonInit();
	}); 
</script>

<BODY topmargin="0" leftmargin="0">
<!-- #include virtual=/inc/menu.inc.asp -->  

<style>
	.calCellHead { float:left; width:175px; height:30px; border-left:1px #abccf8 solid; border-top:1px #abccf8 solid; border-bottom:1px #abccf8 solid; text-align:center; padding-top:5px; font-weight:bold;  background-image:url('/inc/layout/panel-title-light-bg.gif'); margin-bottom:2px; }
	.calCellHeadLast { float:left; width:175px; height:30px; border-left:1px #abccf8 solid; border-top:1px #abccf8 solid; border-bottom:2px #006600 solid; border-right:1px #abccf8 solid; text-align:center; padding-top:5px; font-weight:bold; background-image:url('/inc/layout/panel-title-light-bg.gif'); margin-bottom:2px; }
	.calCellBody { float:left; width:175px; height:120px; border-left:1px #abccf8 solid; border-bottom:1px #abccf8 solid; padding:5px 0 0 5px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
	.calCellBodyLast { float:left; width:175px; height:120px; border-left:1px #abccf8 solid; border-bottom:2px #006600 solid; border-right:1px #abccf8 solid;  padding:5px 0 0 5px; background-color:#ececff;text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
</style>

<!-- 검색 영역 시작 -->
<div style="text-align:left;margin-top:10px;">
<table border="0" cellpadding="0" cellspacing="0" width="1242">
	<tr>
		<td width="250">
		<!-- #include virtual=/inc/subMenu.inc.asp --> 
		</td>
		<td align="right">
			<table border="0" cellpadding="0" cellspacing="0" width="972">
				<tr>
					<td width="100%" class="lTD_trbl" style="height:26px;padding-left:10px;color:#6600ff; background-color:#eaf2fd;" id="topNotice">&nbsp;</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="1237" style="margin-left:5px"><tr><td style="height:5px"></td></tr></table>
<table border="0" cellpadding="0" cellspacing="0" width="1237" style="margin-left:5px">
	<tr>
		<td width="100%" valign="top" style="height:20px;text-align:right;padding-right:10px">
			[<span id="prevMonthBad">0</span> / <span id="curMonthBad" style="font-size:15px;font-weight:bold;color:#FF0000">0</span>] | [<a title="<%=bfWeekStart%>~<%=bfWeekEnd%>"><%=bfWeekBadRateTxt%></a> / <a title="<%=curWeekStart%>~<%=curWeekEnd%>"><%=curWeekBadRateTxt%></a>]
		</td>
	</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="1237" style="margin-left:5px;">
	<tr height="40">
		<td style="padding: 0px 0 0px 10px;background-image:url(/inc/layout/panel-title-light-bg.gif);font-weight:bold;text-align:left" width="100%" class="lTD_trbl">
			기준월 <input type="text" name="findMonth" id="findMonth" class="inputBox" style="width:80px;ime-Mode:active" value="<%=Left(Date(),7)%>"> &nbsp;
			  <select id="findProcType">
			  <% if cp = "on" then %>
				<option value="extra">가공(2팀)</option>
			  <% else %>
			  	<%=pTypes%>
			  	<!--
				<option value="10">가공</option>
				<option value="20">검사</option>
				<option value="80">포장(외주)</option>
				<option value="90">포장</option>
				<option value="98">출하</option>
				-->
				<option value="inventory">검사+포장</option>
				<option value="100">원자재</option>
				<option value="equip">장비</option>
				<option value="offwork">휴일근무</option>
			<% end if %>
			</select>&nbsp;
			<input type="button" onClick="fnShowCalendar()" value="검 색" class="inputBtn">&nbsp;
			<input type="button" onClick="fnSearchReset()" value="Reset" class="inputBtn">
		</td>
	</tr>
</table>
</div>
<!-- 검색 영역 끝 -->
<table border="0" cellpadding="0" cellspacing="0" width="1237" style="margin-left:5px"><tr><td style="height:5px"></td></tr></table>
<!-- 그리드 시작 -->
<div style="text-align:left">
<table border="0" cellpadding="0" cellspacing="0" width="1235" style="margin-left:5px;text-align:left">
	<tr>
		<td width="100%" class="lTD_trbl" style="padding: 5px 5px 5px 5px;">
			<div id="calMonth" style="width:1225px;border-bottom:1px #abccf8 solid;" class="calCellHeadLast">
			</div>
			<div style="width:1225px;">
				<div class="calCellHead" style="border-bottom:2px #ff0000 solid;">일요일</div>
				<div class="calCellHead">월요일</div>
				<div class="calCellHead">화요일</div>
				<div class="calCellHead">수요일</div>
				<div class="calCellHead">목요일</div>
				<div class="calCellHead">금요일</div>
				<div class="calCellHeadLast">토요일</div>
			</div>
			<div id="calendarBody" style="width:1225px;border-top:1px #abccf8 solid;">
			</div>
		</td>
	</tr>
</table>
</div>
<!-- 그리그 끝 -->
<div id="noticeContents" style="display:none;position:absolute;width:470px;background-color:#feecd3;border:#ff6600 1px solid;padding:10px 10px 10px 10px; z-index:2">
	<table cellpadding="0" cellspacing="0" border="0" width="450">
		<tr>
			<td style="font-weight:bold;height:40px"> &nbsp; [공지사항] <span id="vTitles"></span></td>
		</tr>
			<td style="text-align:center"><textarea id="contents" class="inputBox" style="width:440px; height:300px" readonly="readonly"></textarea></td>
		</tr>
		<tr>
			<td colspan="2" width="100%" style="text-align:right;height:28px;padding-right:8px;"><input type="button" onClick="fnLayerClose('noticeContents')" value="닫기" class="inputBtn"></td>
		</tr>
	</table>
</div>

<div id="offDayWorks" style="display:none;position:absolute;width:420px;background-color:#fff;border:#ff6600 1px solid;padding:10px 10px 10px 10px; z-index:3">
<table border="0" cellpadding="0" cellspacing="0" width="400">
	<form name="frmOffDayWork">
	<tr>
		<td height="30" width="400" class="lTD_00b0" style="padding: 0 0 0 20px; text-align:left; font-weight:bold">
			근 &nbsp;&nbsp; 무 &nbsp;&nbsp; 자 &nbsp;&nbsp; : &nbsp;<select id="userId"><option value="">--근무자--</option><%=userAll%></select>
		</td>
	</tr>
	<tr>
		<td height="30" width="400" class="lTD_00b0" style="padding: 0 0 0 20px; text-align:left; font-weight:bold">
			근 &nbsp;&nbsp; 무 &nbsp;&nbsp; 일 &nbsp;&nbsp; :&nbsp;
			<input type="text" id="workDt" size="13" readOnly class="specialBox" onclick="Calendar_D(document.frmOffDayWork.workDt);"> &nbsp; 
			<select id="workTm">
				<option value="">--근무시간--</option>
				<!--<option value="1">1시간</option>-->
				<option value="2">2시간</option>
				<option value="3">3시간</option>
				<option value="4">4시간</option>
				<option value="5">5시간</option>
				<option value="6">6시간</option>
				<option value="7">7시간</option>
				<option value="8">8시간</option>
				<option value="9">9시간</option>
				<option value="10">10시간</option>
				<option value="99">정상근무</option>
				<option value="88">휴가</option>
			</select>
		</td>
	</tr>
	<tr style="display:<%=isPerm%>">
		<td height="30" width="400" class="lTD_00b0" style="padding: 0 0 0 20px; text-align:right; font-weight:bold">
			<input type="button" value="저장" class="inputBtn" onClick="fnOffSave()"> 
			<input type="button" value="닫기" class="inputBtn" onClick="fnOffClose()">
		</td>
	</tr>
	</form>
</table>
</div>

</BODY>
</HTML>